package pl.edu.utp.ga.genes;

import java.util.Random;

public class BinaryGene extends BasicGene<Boolean>{

	private Random random = new Random();
	
	public BinaryGene(){
		generate();
	}
	
	public BinaryGene(Boolean gene){
		this.gene = gene;
	}
	
	@Override
	public Boolean generate() {
		gene = random.nextBoolean();
		return gene;
	}

	@Override
	public void mutate(Boolean mutation) {
		gene = (gene ^ mutation);
	}
	
	public String toString(){
		return String.format("%d", gene ? 1 : 0);
	}
}
